package main

import (
	"ota-go/database"
	"ota-go/web"
)

func main() {
	go initUse()
	select {}
}

func initUse() {
	//创建初始化数据库
	sqliteHelper := database.CreateSqliteHelper("ota.db")
	sqliteHelper.CreateTable()
	db := sqliteHelper.DB
	var user database.User
	tx := db.Where("user_name=?", "admin").First(&user)
	if tx.Error != nil {
		db.Create(&database.User{UserName: "admin", Password: "123456", Type: 1})
	}

	webHelper := web.CreateWebHelper(db)
	webHelper.RegisterInterfaces()
	webHelper.Run()
}
